import React from 'react'
import * as Router from  "react-router";
import * as UI from 'antd-mobile'
import * as ICON from 'antd-mobile-icons'
import request from '@/services/request'
import Cookie from 'react-cookies'

React.Router = Router;
React.UI = UI
React.ICON = ICON
React.HTTP = request
React.Cookie = Cookie

// 成功提醒方法
React.success = (msg:string, callback?: Function) => 
{
   React.UI.Toast.show({
        icon: 'success',
        content: msg,
        duration: 1500,
        afterClose: callback ? callback : () =>{}
    })
}

// 失败提醒方法
React.error = (msg:string, callback?: Function) => 
    {
       React.UI.Toast.show({
            icon: 'fail',
            content: msg,
            duration: 1500,
            afterClose: callback ? callback : () =>
            {
                React.navigate(-1)
            }
        })
    }